<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/7
 * Time: 15:29
 */

namespace App\Api\Admin\Controllers;

use App\Exceptions\ApiException;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Cache;

class CommonController extends Controller
{
    public $user;

    public function __construct()
    {
        $token = IT('ticket', true, '请先登录');
        $this->user = Cache::get($token);
        if (!$this->user) {
            throw new ApiException('暂未登录');
        }
    }
    /**
     * 登出
     * @return array
     */
    public function logout()
    {
        if ($this->user) {
            $token = IT('ticket', true, '请先登录');
            Cache::forget($token);
        }
        return json_success('ok');
    }
}